import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:raze/potions/raze_constant.dart';
import 'package:raze/potions/spatial_alchemy.dart';

/// 日志删除确认弹窗
/// 用于确认删除日志操作
class DiaryDeletionDialog {
  /// 显示日志删除确认弹窗
  /// [onConfirm] 确认删除的回调
  static void revealDeletionConfirmation({required VoidCallback onConfirm}) {
    Get.dialog(
      _DiaryDeletionDialogWidget(onConfirm: onConfirm),
      barrierDismissible: true,
      barrierColor: RazeConstants.black.withOpacity(0.5),
    );
  }
}

class _DiaryDeletionDialogWidget extends StatelessWidget {
  final VoidCallback onConfirm;

  const _DiaryDeletionDialogWidget({required this.onConfirm});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Material(
        color: Colors.transparent,
        child: Container(
          margin: EdgeInsets.symmetric(horizontal: 24.w),
          padding: EdgeInsets.all(24.w),
          decoration: BoxDecoration(
            color: RazeConstants.white,
            borderRadius: BorderRadius.circular(24.r),
            border: Border.all(color: RazeConstants.black, width: 2.w),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              // 提示文本
              Text(
                    'Are you sure you want to delete this diary entry?',
                    textAlign: TextAlign.center,
                  )
                  .applyTypeSize(16.sp)
                  .applyTypeColor(RazeConstants.black)
                  .applyNotoSans(weight: FontWeight.w500),
              24.h.boxHeight,

              // 按钮行
              Row(
                children: [
                  // Cancel 按钮
                  Expanded(
                    child: Container(
                          height: 50.h,
                          decoration: BoxDecoration(
                            color: RazeConstants.yellow,
                            borderRadius: BorderRadius.circular(16.r),
                            border: Border.all(
                              color: RazeConstants.black,
                              width: 2.w,
                            ),
                          ),
                          child: Center(
                            child: Text('Cancel')
                                .applyTypeSize(16.sp)
                                .applyTypeColor(RazeConstants.black)
                                .applyNotoSans(weight: FontWeight.w600),
                          ),
                        )
                        .withRightBottomShadow(thickness: 1.5)
                        .withTouchResonance(onTap: () => Get.back()),
                  ),

                  16.w.boxWidth,

                  // Delete 按钮
                  Expanded(
                    child: Container(
                          height: 50.h,
                          decoration: BoxDecoration(
                            color: RazeConstants.red,
                            borderRadius: BorderRadius.circular(16.r),
                            border: Border.all(
                              color: RazeConstants.black,
                              width: 2.w,
                            ),
                          ),
                          child: Center(
                            child: Text('Delete')
                                .applyTypeSize(16.sp)
                                .applyTypeColor(RazeConstants.white)
                                .applyNotoSans(weight: FontWeight.w600),
                          ),
                        )
                        .withRightBottomShadow(thickness: 1.5)
                        .withTouchResonance(
                          onTap: () {
                            Get.back();
                            onConfirm();
                          },
                        ),
                  ),
                ],
              ),
            ],
          ),
        ).withRightBottomShadow(thickness: 2),
      ),
    );
  }
}
